package com.hsgene.version.service.api;

import com.hsgene.common.util.result.ApiResult;
import com.hsgene.version.service.api.impl.GeneratorServiceImpl;
import com.hsgene.generator.dto.GeneratorDto;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * id生成器服务
 *
 * @author wangbing
 * @version 1.0, 2018/7/14
 */
@FeignClient(value = "ms-mod-generator", path = "/v1.0/genetic/testing/generator", fallback = GeneratorServiceImpl.class)
public interface GeneratorService {

    /**
     * 根据type类型生成相应编号
     *
     * @param type   编号类型
     * @param prefix 编号前缀（可空）
     * @return 生成结果
     */
    @GetMapping
    ApiResult<GeneratorDto> getGenerator(@RequestParam("type") String type, @RequestParam("prefix") String prefix);

    /**
     * 获取编号
     *
     * @param prefixType   前缀
     * @param workerId     工作号
     * @param datacenterId 数据中心id
     * @return
     */
    @GetMapping("number")
    ApiResult<GeneratorDto> numberGenerator(@RequestParam("prefixType") String prefixType,
                                            @RequestParam("workerId") Integer workerId,
                                            @RequestParam("datacenterId") Integer datacenterId);
}
